package com.housekeeping.housekeeping.order.service.impl;

import com.housekeeping.housekeeping.order.dao.impl.OrderDaoImpl;
import com.housekeeping.housekeeping.order.entity.Order;
import com.housekeeping.housekeeping.order.service.OrderPageSev;
import com.housekeeping.housekeeping.order.utils.PageUtils;

import java.sql.SQLException;
import java.util.List;

public class OrderPageSevImpl implements OrderPageSev {
    private OrderDaoImpl orderDao = new OrderDaoImpl();
    @Override
    public PageUtils<List<Order>> getPageList(int currentPage, int pageSize) throws SQLException {
        //数据库操作
        List<Order> pageList = orderDao.getPageList((currentPage - 1) * pageSize, pageSize);
        int totalCount = orderDao.getTotalCount();
        PageUtils<List<Order>> pageObj = new PageUtils<>();
        pageObj.setData(pageList);
        pageObj.setTotalCount(totalCount);
        //【设置改变当前页】
        pageObj.setCurrentPage(currentPage);

        return pageObj;
    }
}
